//
//  UIBarButtonItem+WZPbtn.m
//  WZPItem
//
//  Created by 王王喆平 on 16/7/3.
//  Copyright © 2016年 UI. All rights reserved.
//

#import "UIBarButtonItem+WZPbtn.h"

@implementation UIBarButtonItem (WZPbtn)
+(instancetype)itemWithImage:(UIImage *)image hlightImage:(UIImage *)hlightImage target:(id)target action:(SEL)action{
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:hlightImage forState:UIControlStateHighlighted];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView * containerView = [[UIView alloc]initWithFrame:btn.bounds];
    [containerView addSubview:btn];
    return [[UIBarButtonItem alloc]initWithCustomView:containerView];
        return [[UIBarButtonItem alloc] initWithCustomView:containerView];

}
+(instancetype)itemWithImage:(UIImage *)image setImage:(UIImage *)setImage target:(id)target action:(SEL)action{
    
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:setImage forState:UIControlStateSelected];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    UIView * containerView = [[UIView alloc]initWithFrame:btn.bounds];
    [containerView addSubview:btn];
    return [[UIBarButtonItem alloc]initWithCustomView:containerView];
    return [[UIBarButtonItem alloc] initWithCustomView:containerView];
}
@end
